package cn.wolfcode.esdemo.domain;

import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor

//表名该类对应而是中的索引和类型
@Document(indexName = "es_shop", type = "shop_product")
public class Product {
    //对应es中的id字段
    @Id
    private String id;

    //字段要和es设置的一样，否则会报错
    @Field(analyzer = "ik_smart", searchAnalyzer = "ik_smart", type = FieldType.Text)
    private String title;

    private Integer price;
    @Field(analyzer = "ik_smart", searchAnalyzer = "ik_smart", type = FieldType.Text)
    private String intro;

    @Field(type = FieldType.Keyword)
    private String brand;
}
